package com.zhaopin.thread;

/**
 * @author yin.peide
 */ //: SimpleThread.java
// Very simple Threading example
public class SimpleThread extends Thread {
    private int countDown = 5;
    private int threadNumber;
    private static int threadCount = 0;

    public SimpleThread() {
        threadNumber = ++threadCount;
        System.out.println("Making " + threadNumber);
    }

    @Override
    public void run() {
        while (true) {
            System.out.println("Thread " +
                    threadNumber + "(" + countDown + ")");
            if (--countDown == 0) {
                return;
            }
        }
    }

    public static void main(String[] args) {
        Thread thread1 = new SimpleThread();
        Thread thread2 = new SimpleThread();
        Thread thread3 = new SimpleThread();
        Thread thread4 = new SimpleThread();
        Thread thread5 = new SimpleThread();
        thread1.setPriority(5);
        thread2.setPriority(4);
        thread3.setPriority(3);
        thread4.setPriority(2);
        thread5.setPriority(1);
        thread5.start();
        thread4.start();
        thread3.start();
        thread2.start();
        thread1.start();
        System.out.println("All Threads Started");
    }
} ///:~
